package cn.humaohua.study.yanmo_design_pattern.ch04.v3;

import cn.humaohua.study.yanmo_design_pattern.ch04.v1.LogFileOperateApi;
import cn.humaohua.study.yanmo_design_pattern.ch04.v1.LogModel;
import cn.humaohua.study.yanmo_design_pattern.ch04.v1.LogModelUtil;
import cn.humaohua.study.yanmo_design_pattern.ch04.v2.LogDbOperateApi;

import java.util.List;


// 让适配器实现数据库日志操作接口
public class Adapter implements LogDbOperateApi {

    // 实际要把日志文件存到文件中，需要持有一个文件日志操作对象
    private LogFileOperateApi logFileOperate;

    public Adapter(LogFileOperateApi logFileOperate) {
        super();
        this.logFileOperate = logFileOperate;
    }

    @Override
    public void createLog(LogModel logModel) {
        logFileOperate.writeLogFile(LogModelUtil.INSTANCE.genLogModel());
    }

    @Override
    public List<LogModel> getAllLog() {
        List<LogModel> list = logFileOperate.readLogFile();
        System.out.println(list);
        return null;
    }

}
